package com.fwtai.service.api;

import com.fwtai.api.ApiVideosDao;
import com.fwtai.bean.PageFormData;
import com.fwtai.service.AsyncService;
import com.fwtai.tool.ToolClient;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * 视频号
 * @作者 田应平
 * @版本 v1.0
 * @QQ号码 444141300
 * @创建日期 2021年8月4日 15:02:35
 * @官网 <url>http://www.fwtai.com</url>
*/
@Service
public class ApiVideosService{

    @Resource
    private ApiVideosDao apiVideosDao;

    @Resource
    private AsyncService asyncService;

    public String getListVideo(final HttpServletRequest request){
        final PageFormData formData = ToolClient.pageParamsApi(request);
        if(formData == null) return ToolClient.jsonValidateField();
        return ToolClient.jsonPage(apiVideosDao.getListVideo(formData));
    }

    public void updateBrowse(final String kid){
        if(kid != null && kid.length() > 0){
            asyncService.updateVideoBrowse(kid);
        }
    }

    public String getHomeData(){
        return ToolClient.queryJson(apiVideosDao.getHomeData());
    }

}